home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 20 code / NetWare Development / NLM Client Example / NLMClientApp.cp < prev    next >
Encoding:
Text File  |  1994-10-06  |  6.5 KB  |  222 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. //    NLMClientApp.cp    
  3. // ===========================================================================
  4. //
  5. //    This program works with the ATDemo NetWare NLM.  It acts as the client
  6. //    that makes a connection with the server and sends certain server
  7. //    statistics requests.
  8. //    
  9. //    This program is NOT necessarily the model of good programming.  The attention
  10. //    has been spent on the server side.  However, if you wish to use this
  11. //    as a starter program, feel free.
  12. //
  13. //    This program was written with Metrowerks C/C++ for 68k, using the
  14. //    PowerPlant class hierarchy.
  15. //
  16. //    It was written by Nick Brosnahan and Jamie Osborne. 9/94
  17. //
  18. // Apple Computer, Inc. makes no warranties about the the fitness of this code
  19. // for any purpose and will not be held liable for any damages you may suffer
  20. // from using this code.  Furthermore, Apple Computer, Inc. will not be held
  21. // liable for the death of Elvis or any other space alien.
  22. //
  23. // Your mileage may vary.
  24.  
  25. #pragma once
  26.  
  27. #include "NLMClientApp.h"
  28. #include "LServerChooser.h"
  29. #include "LServerActions.h"
  30.  
  31. #include <PP_Messages.h>
  32. #include <LApplication.h>
  33. #include <LGrowZone.h>
  34. #include <UMemoryMgr.h>
  35. #include <UDrawingState.h>
  36. #include <URegistrar.h>
  37. #include <UPowerTools.h>
  38.  
  39. const ResIDT    WIND_ServerChooser    = 1000;
  40. const ResIDT    WIND_ServerActions    = 1001;
  41.  
  42. const MessageT    cmd_DoServerChooser = 1001;
  43. const MessageT    cmd_DoServerActions = 1002;
  44.  
  45. NLMClientApp *gApplication;
  46.  
  47. // ===========================================================================
  48. //        • Main Program
  49. // ===========================================================================
  50.  
  51. void main(void)
  52. {
  53.                                     // Set Debugging options
  54. #ifdef Debug_Throw
  55.     gDebugThrow = debugAction_Alert;
  56. #endif
  57.  
  58. #ifdef Debug_Signal
  59.     gDebugSignal = debugAction_Alert;
  60. #endif
  61.  
  62.     InitializeHeap(3);                // Initialize Memory Manager
  63.                                     // Parameter is number of Master Pointer
  64.                                     //   blocks to allocate
  65.     
  66.                                     // Initialize standard Toolbox managers
  67.     UQDGlobals::InitializeToolbox(&qd);
  68.     
  69. #ifdef Debug_Signal                    // Check for missing MBAR, which
  70.     CheckForInitialMBAR();            // probably means that there is no
  71. #endif                                // project resource file
  72.     
  73.     new LGrowZone(20000);            // Install a GrowZone function to catch
  74.                                     //    low memory situations.
  75.                                     //    Parameter is size of reserve memory
  76.                                     //    block to allocated. The first time
  77.                                     //    the GrowZone function is called,
  78.                                     //    there will be at least this much
  79.                                     //    memory left (so you'll have enough
  80.                                     //    memory to alert the user or finish
  81.                                     //    what you are doing).
  82.     
  83.     NLMClientApp    theApp;            // Create instance of your Application
  84.     gApplication = &theApp;
  85.     theApp.Run();                    //   class and run it
  86. }
  87.  
  88.  
  89. // ===========================================================================
  90. //        • NLMClientApp Class
  91. // ===========================================================================
  92.  
  93. // ---------------------------------------------------------------------------
  94. //        • NLMClientApp
  95. // ---------------------------------------------------------------------------
  96. //    Constructor
  97.  
  98. NLMClientApp::NLMClientApp()
  99. {
  100.         // Register classes for objects created from 'PPob' resources
  101.         // For PowerPlant classes, you can copy the necessary RegisterClass
  102.         // calls from PPobClasses.cp
  103.         //
  104.         // For your own classes, you must use the same four-character ID as
  105.         // you specify in the 'PPob' resource (or in Constructor).
  106.         // PowerPlant reserves all ID's composed entirely of lower case
  107.         // letters.
  108.         
  109.     URegistrar::RegisterClass('sact', (ClassCreatorFunc) LServerActions::CreateServerActionsStream);
  110.     URegistrar::RegisterClass('scho', (ClassCreatorFunc) LServerChooser::CreateServerChooserStream);
  111.     URegistrar::RegisterClass('lbox', (ClassCreatorFunc) LListBox::CreateListBoxStream);
  112.     URegistrar::RegisterClass('pbut', (ClassCreatorFunc) LStdButton::CreateStdButtonStream);
  113.     URegistrar::RegisterClass('capt', (ClassCreatorFunc) LCaption::CreateCaptionStream);
  114.     URegistrar::RegisterClass('edit', (ClassCreatorFunc) LEditField::CreateEditFieldStream);
  115.  
  116. }
  117.  
  118.  
  119. // ---------------------------------------------------------------------------
  120. //        • ~NLMClientApp
  121. // ---------------------------------------------------------------------------
  122. //    Destructor
  123.  
  124. NLMClientApp::~NLMClientApp()
  125. {
  126.         // +++ Add code here to cleanup (if necessary) before quitting
  127. }
  128.  
  129.  
  130. // ---------------------------------------------------------------------------
  131. //        • ObeyCommand
  132. // ---------------------------------------------------------------------------
  133. //    Respond to commands
  134.  
  135. Boolean
  136. NLMClientApp::ObeyCommand(
  137.     CommandT    inCommand,
  138.     void        *ioParam)
  139. {
  140.     Boolean    cmdHandled = true;
  141.     
  142.     switch (inCommand) {
  143.     
  144.         // +++ Add cases here for the commands you handle
  145.         //        Remember to add same cases to FindCommandStatus below
  146.         //        to enable/disable the menu items for the commands
  147.         
  148.         case cmd_DoServerChooser:
  149.             DoServerChooser();
  150.             break;
  151.  
  152. /*        case cmd_DoServerActions:
  153.             mServerActions->Show();
  154.             break;            
  155. */        
  156.         default:
  157.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  158.             break;
  159.     }
  160.     
  161.     return cmdHandled;
  162. }
  163.  
  164.  
  165. // ---------------------------------------------------------------------------
  166. //        • FindCommandStatus
  167. // ---------------------------------------------------------------------------
  168. //    Pass back status of a (menu) command
  169.  
  170. void
  171. NLMClientApp::FindCommandStatus(
  172.     CommandT    inCommand,
  173.     Boolean        &outEnabled,
  174.     Boolean        &outUsesMark,
  175.     Char16        &outMark,
  176.     Str255        outName)
  177. {
  178.     outUsesMark = false;
  179.     outEnabled = FALSE;
  180.     
  181.     switch (inCommand) {
  182.     
  183.         // +++ Add cases here for the commands you handle.
  184.         //
  185.         //        Set outEnabled to TRUE for commands that can be executed at
  186.         //        this time.
  187.         //
  188.         //        If the associated menu items can have check marks, set
  189.         //        outUsesMark and outMark accordingly.
  190.         //
  191.         //        Set outName to change the name of the menu item
  192.     
  193.         case cmd_DoServerChooser:
  194. //            if (!mServerChooser->IsVisible())
  195.                 outEnabled = TRUE;
  196.             break;
  197.             
  198.         case cmd_DoServerActions:
  199. //            if ((!mServerChooser->IsVisible())&&(!mServerActions->IsVisible()))
  200. //                outEnabled = TRUE;
  201.             break;
  202.             
  203.         case cmd_Close:
  204. //            if (mServerActions->IsVisible())
  205. //                outEnabled = TRUE;
  206.             break;
  207.     
  208.         default:
  209.             LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  210.                                 outMark, outName);
  211.             break;
  212.     }
  213. }
  214.  
  215. void NLMClientApp::DoServerChooser()
  216. {
  217.     LServerChooser *serverChooser;
  218.     serverChooser = (LServerChooser *)LServerChooser::CreateWindow(WIND_ServerChooser, this);
  219.     serverChooser->DoSetupServerChooser();
  220.  
  221. }
  222.